package com.lianniu.web.app.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianniu.web.app.service.IAppVersionControlService;
import com.lianniu.web.app.service.IStatistiCallListAppService;
import com.lianniu.web.app.util.IpUtil;
import com.lianniu.web.app.vo.SessionRetnVo;
import com.lianniu.web.base.BaseResult;
import com.lianniu.web.util.StringUtil;

@Controller
@RequestMapping("/rest/app")
public class AppRestController {
    @Autowired
    IAppVersionControlService appVersionControlService;
   
    @Autowired
    IStatistiCallListAppService statistiCallListAppService;
    
    @RequestMapping(value = "/queryVersion", method = { RequestMethod.GET,RequestMethod.POST })
    @ResponseBody
    public BaseResult queryVersion(HttpServletRequest request, HttpServletResponse response){
        /*String version=request.getParameter("version");
        String sys=request.getParameter("sys");*/
        String version = "1";
        String sys = "1";
        if(StringUtil.isEmpty(sys)||StringUtil.isEmpty(version)){
            return null;
        }
       BaseResult baseResult=appVersionControlService.getAppVersionControlVo(version, sys);
       //SessionRetnVo vo = (SessionRetnVo)baseResult.getData();
        return baseResult;
    }
    
    
    @RequestMapping(value = "/statistical", method = { RequestMethod.GET,RequestMethod.POST })
    public  @ResponseBody String statistical(HttpServletRequest request, HttpServletResponse response){
        String sys=request.getParameter("sys");
        String type=request.getParameter("type");
        if(StringUtil.isEmpty(sys)||StringUtil.isEmpty(type)){
            return null;
        }
        String ip = IpUtil.getIP4(request);
        statistiCallListAppService.statisticalNum(ip,sys, type);
        return null;
    }
}
